package main

import (
	"fmt"
	"gitee.com/mootok/mootok/src/constant/strings"
	"gitee.com/mootok/mootok/src/models"
	"gitee.com/mootok/mootok/src/storage/database"
)

func main() {

	err := database.Client.AutoMigrate(
		&models.User{},
		&models.UploadTask{},
		&models.Video{},
		&models.VideoCategory{},
		&models.Category{},
		&models.Collection{},
		&models.UserVideoCollectionRelation{},
		&models.FollowRelation{},
		&models.UserVideoFeedRelation{},
		&models.VideoTranscodingTask{},
		&models.VideoLike{},
		&models.UserPreference{},
	)
	categories := []models.Category{
		{ID: strings.CategoryHot, Name: "热门"},
		{ID: strings.CategoryFeed, Name: "关注"},
		{ID: strings.CategoryRecommendation, Name: "推荐"},
	}

	for i := 0; i < len(categories); i++ {
		database.Client.Where("id = ?", categories[i].ID).FirstOrCreate(&categories[i])
	}

	if err != nil {
		panic(fmt.Errorf("db migrate failed: %v", err))
	}

}
